Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(codemods): add codemod to upgrade V1 Buttons #5408

Draft
wants to merge 12 commits into
base: main
Choose a base branch
from

Conversation

HeartSquared
Copy link
Contributor

@HeartSquared HeartSquared commented Dec 19, 2024

Why

Make adoption easier.

What

Codemod to upgrade Button v1/v2 and IconButton v1/v2 to Button v3 or LinkButton v3

Assumptions:

  • label should always exist, and become children
  • children should not already exist (always a self-closing element)

Props:

  • onClickonPress
  • labelchildren (self-closing → open/close element)
    • Examples of different types of label usage:
      • "Actions"
      • {"Actions for section" // TODO: i18n}
      • {"Back to Main Menu"}
      • {`Further options for ${track.name}`}
      • { showEmojiPicker ? formatMessage({ id: "liteRTE.emojiPickerLabel.close", defaultMessage: "Close emoji picker", description: "Label for the button that closes the emoji picker", }) : formatMessage({ id: "liteRTE.emojiPickerLabel.open", defaultMessage: "Open emoji picker", description: "Label for the button that opens the emoji picker", }) }
      • {label}
  • Update variants
    • Default (undefined):
      • Button -> variant secondary
      • IconButton -> variant tertiary
    • primary → variant primary
    • secondary → variant tertiary
    • destructive → delete
  • Update size
    • regularlarge
    • smallmedium
    • There is a usage of size={size} which would likely have a TS error - leave as is
  • reversedisReversed
  • classNameOverrideclassName
  • data-automation-iddata-testid
  • disabledisDisabled
  • newTabAndIUnderstandTheAccessibilityImplicationstarget="_blank"
    • Also add rel="noopener noreferrer"
  • IconButton only:
    • Add hasHiddenLabel

Component name:

  • IconButton (v1/v2) without href or componentButton (v3)
  • IconButton (v1/v2) with hrefLinkButton
  • IconButton (v1/v2) with componentLinkButton
  • Button (v1/v2) without href or componentButton (v3)
  • Button (v1/v2) with hrefLinkButton
  • Button (v1/v2) with componentLinkButton

Imports:

  • From:
    • @kaizen/components
    • @kaizen/components/v1/actions
    • @kaizen/components/v2/actions
  • To:
    • @kaizen/components/v3/actions
  • IconButton may be aliased - use alias
  • Button may be aliased - use alias
  • Button (v3) not imported - add import
  • Button (v3) may already be used
    • Do not add an additional import
    • Button may be aliased - use alias

Copy link

changeset-bot bot commented Dec 19, 2024

🦋 Changeset detected

Latest commit: deb46b1

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@kaizen/components Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Base automatically changed from heartsquared/codemod-fix--upgradeIconV1 to main December 19, 2024 05:08
@HeartSquared HeartSquared force-pushed the KZN-2846/codemod--upgrade-button branch from 75ed8ab to 1cd8163 Compare December 19, 2024 05:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant